package com.miaoxun.dao;

import com.miaoxun.dao.provider.UserRoleProvider;
import com.miaoxun.domain.entity.UserRole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import com.basemapper.BasicMapper;

import java.util.List;

/**
 * 用户与角色对应关系
 *
 * @author ruoshuisixue
 * @email ruoshuisixue@sina.com
 * @date 2017-11-17 14:38:42
 */
@Mapper
@Component
public interface UserRoleMapper extends BasicMapper<UserRole> {

    @SelectProvider(type = UserRoleProvider.class, method = "listRoleId")
    List<Long> listRoleId(Long id);

    @SelectProvider(type = UserRoleProvider.class, method = "removeByUserId")
    void removeByUserId(Long userId);

    @InsertProvider(type = UserRoleProvider.class, method = "batchSave")
    void batchSave(@Param("list") List<UserRole> list);

    @Delete("delete from user_role where user_id=#{id}")
    void deleteByUserId(Long id);
}
